package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class ReflectDemo7 {          //单例
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Singleton s1 = Singleton.getInstance();
        Singleton s2 = Singleton.getInstance();
        System.out.println(s1);
        System.out.println(s2);

        Class cls = Class.forName("reflect.Singleton");
        Constructor c = cls.getDeclaredConstructor();
        c.setAccessible(true);
        Object o = c.newInstance();
        c.setAccessible(false);

        System.out.println(o);

    }
}
